package com.heima.wemedia.controller.v1;


import com.heima.model.comment.dtos.CommentListDto;
import com.heima.model.comment.dtos.CommentArticleDto;
import com.heima.model.comment.dtos.CommentOperationDto;
import com.heima.model.comment.dtos.WmCommentRepayDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.pojos.ApCommentLikeDto;
import com.heima.wemedia.service.CommentManageService;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @projectName: heima-leadnews0802
 * @package: com.heima.admin.controller.v1
 * @className: AdCommentController
 * @author: AoQing
 * @date: 2023/8/2 9:16
 * @version: 1.0
 */

@RestController
@RequestMapping("/api/v1/comment/manage")
public class CommentManageController {

    @Autowired
    private CommentManageService commentManageService;

    /**
     * 查看评论列表
     * @param commentListDto
     * @return
     */
    @PostMapping("/list")
   public ResponseResult commentList(@RequestBody CommentListDto commentListDto){

      return commentManageService.list(commentListDto);
   }

    /**
     * 打开或者关闭评论
     * @param dto
     * @return
     */
   @PostMapping("/update_comment_status")
   public ResponseResult openOrCloseComment(@RequestBody CommentOperationDto dto){
        return commentManageService.openOrCloseComment(dto);
   }

    /**
     * 查询文章和评论
     * @return
     */
   @PostMapping("/find_news_comments")
   public ResponseResult findNewsComments(@RequestBody CommentArticleDto dto){
    return    commentManageService.findNewsComments(dto);

   }

    /**
     * 作者删除评论
     * @param commentId
     * @return
     */
   @DeleteMapping("del_comment/{commentId}")
   public ResponseResult delComment(@PathVariable String commentId){

        return commentManageService.delComment(commentId);
   }

    /**
     * 作者评论点赞
     * @param dto
     * @return
     */
   @PostMapping("/like")
    public ResponseResult like(@RequestBody ApCommentLikeDto dto){
        return commentManageService.like(dto);
    }


    /**
     * 删除回复评论
     * @return
     */
    @PostMapping("/del_comment_repay/{commentRepayId}")
    public ResponseResult delCommentReply(@PathVariable String commentRepayId){
        return commentManageService.delCommentReply(commentRepayId);
    }

    /**
     * 回复评论
     * @param dto
     * @return
     */
    @PostMapping("/comment_repay")
    public ResponseResult commentRepay(@RequestBody WmCommentRepayDto dto){
        return commentManageService.commentRepay(dto);
    }
}
